import cv2
import  imgShow.Img as imgShow

img = cv2.imread('1.jpg', cv2.IMREAD_GRAYSCALE)
new_imgx = cv2.Sobel(img, cv2.CV_64F, 1, 0, ksize=3)
abs_imgx = cv2.convertScaleAbs(new_imgx)
new_imgy = cv2.Sobel(img, cv2.CV_64F, 0, 1, ksize=3)
abs_imgy = cv2.convertScaleAbs(new_imgy)
result_img = cv2.addWeighted(abs_imgx, 0.5, abs_imgy, 0.5, 0)
imgShow.cv_show(result_img, 'abs_img')